package com.nmc.core.dao;

import java.util.List;

import org.hibernate.Criteria;
import org.hibernate.Session;
import org.hibernate.criterion.Restrictions;

import com.nmc.model.Ward;

public class WardDAOImpl extends BaseDAO implements WardDAO {
	
	
	public List getWardList() {
		
		//System.out.println("IN getWardList()");
		return this.getHibernateTemplate().loadAll(Ward.class);
	}

	
	public String getWardName(int wardId){
		Ward ward = (Ward)this.getHibernateTemplate().get(Ward.class, wardId);
		String name = ward.getName();
		return name;
	}
	public Ward getWard(int wardId){
		return (Ward)this.getHibernateTemplate().get(Ward.class, wardId);
	}
	
	public List getWardList(int zoneId)
	{
		 Session session = this.getSession();
	        Criteria c = session.createCriteria(Ward.class);
	       // c.createAlias("ward", "ward");
	        c.add(Restrictions.eq("zoneId",zoneId));
	        List sList = c.list();
		return sList;
	}

}
